import http from "./request";

export const loginApi = (username,password) => {
  return http({
    url: "http://localhost:12345/api/user/login",
    method: "POST",
    data: {username,password},
  });
};

export const createApi = (obj) => {
  return http({
    url: "http://localhost:12345/api/order/create",
    method: "POST",
    data: {...obj},
  });
};

export const getOrderApi = (id) => {
  return http({
    url: "http://localhost:12345/api/order/getOrder/"+id,
    method: "GET",
    params: {},
  });
};

export const payApi = (obj) => {
  return http({
    url: "http://localhost:12345/api/order/pay",
    method: "POST",
    data: {...obj},
  });
};

// 轮播
export const swiperdataApi = () => {
  return http({
    url: "https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata",
    method: "GET",
    params: {},
  });
};

// 导航
export const catitemsApi = () => {
  return http({
    url: "https://api-hmugo-web.itheima.net/api/public/v1/home/catitems",
    method: "GET",
    params: {},
  });
};

// 瀑布
export const searchApi = () => {
  return http({
    url: "https://api-hmugo-web.itheima.net/api/public/v1/goods/search",
    method: "GET",
    params: {},
  });
};

// 分类
export const categoriesApi = () => {
  return http({
    url: "https://api-hmugo-web.itheima.net/api/public/v1/categories",
    method: "GET",
    params: {},
  });
};

// 搜索
export const searchApis = (query,pagenum) => {
  return http({
    url: "https://api-hmugo-web.itheima.net/api/public/v1/goods/search",
    method: "GET",
    params: {query,pagenum},
  });
};

// 详情
export const detailApi = (goods_id) => {
  return http({
    url: "https://api-hmugo-web.itheima.net/api/public/v1/goods/detail",
    method: "GET",
    params: {goods_id},
  });
};